<template>
  <section class="user-card-wrapper">
    <userAvatar
      :uid="userInfo.id"
      class="user-avatar"
      :src="userInfo.avatar"
    />
    <div class="user-info-wrapper">
      <div class="w-top">
        <span class="u-nickname">{{ userInfo.nickname }}</span>
        <span class="u-gender">{{ userInfo.gender }}</span>
        <span
          :title="userInfo.phone"
          :class="['iconfont iconicon_mobilephone', {active:userInfo.phone}]"
        />
        <span
          :title="userInfo.email"
          :class="['iconfont iconicon_dmail', {active:userInfo.email}]"
        />
      </div>
      <!-- <div class="u-desc">{{ userInfo || '没有用户简介' }}</div> -->
      <div class="u-desc">{{ userInfo.desc || '没有用户简介' }}</div>
      <div class="control">
        <span>发送通知</span>
        <span>封禁用户</span>
        <span>设置角色</span>
      </div>
      <section class="other-info">
        <span class="el-icon-date">&nbsp;&nbsp;注册于: {{ userInfo.created_at | parseTime('{y}-{m}-{d}') }}</span>
      </section>
      <section class="u-role iconfont iconicon_boss">
        &nbsp;用户角色组: 普通用户
        <span
          v-for="(role,index) in userRoles"
          :key="index"
        >{{ role.role_name }}</span>
      </section>
    </div>

  </section>
</template>

<script>
export default {
  props: {
    userInfo: {
      type: Object,
      required: true
    }
  },
  computed: {
    userRoles() {
      return this.userInfo.user_account_roles;
    }
  }
};
</script>

<style lang="scss">
@import "~@/styles/variables.scss";

.user-card-wrapper {
  margin: 0 auto 20px;
  padding: 10px;
  position: relative;
  display: flex;
  border: 1px solid #ddd;
  border-radius: 4px;
  .user-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
  }
  .user-info-wrapper {
    width: calc(100% - 80px);
    padding-left: 20px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    // font-weight: bold;
    color: $textGrey;
    .active {
      color: $menuActiveText;
    }
    .u-nickname {
      color: $menuActiveText;
    }
    .u-desc {
      height: 100%;
      padding: 10px 0;
      font-size: 12px;
    }
  }
  .control {
    font-size: 12px;
    * {
      cursor: pointer;
    }
  }
  .other-info {
    right: 10px;
    bottom: 10px;
    position: absolute;
    font-size: 12px;
    transform-origin: right bottom;
    transform: scale(0.9);
  }
  .u-role{
    font-size: 12px;
    position: absolute;
    right: 10px;
    top: 10px;
    transform-origin: right top;
    transform: scale(0.9);
  }
}
</style>
